package com.diver.flinkdemo.mapper.mysqlMapper;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.diver.flinkdemo.entity.xxt.Depart;
import com.diver.flinkdemo.entity.xxt.PersonDepart;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Description: 人员 组织/机构表
 * @Author: jeecg-boot
 * @Date:   2022-05-10
 * @Version: V1.0
 */
public interface PersonDepartMapper extends BaseMapper<PersonDepart> {

	Depart getBindMasterDepart(@Param("personId") String personId);

	@Select("SELECT T2.* FROM (SELECT @r AS _id,(SELECT @r := parent_id FROM bus_depart WHERE id = _id) AS parent_id FROM (SELECT @r := (SELECT depart_id FROM person_depart WHERE person_id = (SELECT person_id FROM person_terminal_info WHERE terminal_id = #{terminalId})),@l :='') vars,bus_depart h WHERE @r is not null) T1 left JOIN bus_depart T2 ON T1._id = T2.id where T1.parent_id = ''")
	Depart getDepartByTerminalId(@Param("terminalId") String terminalId);
}
